package com.itbaizhan.wep;

import com.itbaizhan.pojo.Items;
import com.itbaizhan.pojo.Orders;
import com.itbaizhan.pojo.Users;
import com.itbaizhan.service.UsersService;
import com.itbaizhan.service.impl.UsersServiceImpl;

import java.util.List;
/*关联对象测试*/
public class Test04 {
    public static void main(String[] args) {
        UsersService us = new UsersServiceImpl();
        Users users = us.findUsers(1);
        System.out.println("Users:"+users.getUserid()+" "+users.getUsername()+" "+users.getUserage());
        //输出用户订单信息
        List<Orders> list = users.getOrders();
        for(Orders o:list){
            System.out.println("Orders:"+o.getOrderid()+" "+o.getOrderprice());
            //商品在单订里面
            List<Items> items = o.getItems();
            for (Items items1 : items) {
                System.out.println("Items:"+items1.getItemid()+" "+items1.getItemname()+" "+items1.getItemprice()+" "+items1.getItemnum());

            }

        }
    }
}
